<%@ page
	import="java.util.*,com.db.tracker.vo.*,java.util.*,com.db.tracker.util.*,java.text.*,java.io.*"%>
<%@ page import="com.db.tracker.vo.ReleaseVO"%>
<%
		try {
		System.out
		.println("XXXXXXXXXXXXXXXXX START LOADING JSP PAGE XXXXXXXXXXXXXXXX");
		session = request.getSession();
		//	System.out.println("user_id..main"+ session.getAttribute("USER_ID"));

		if (session.getAttribute("USER_ID") == null
		|| !((String) session.getAttribute("SESSION_ID"))
				.equals(session.getId())) {

			try {
		response.sendRedirect("LoginPage.jsp");
			} catch (IOException ioe) {
		ioe.printStackTrace();
			}

		} else {

			String AddAdminButton = request
			.getParameter("AddAdminButton") == null ? ""
			: request.getParameter("AddAdminButton");
			String AddNewAdmin = request.getParameter("AddNewAdmin") == null ? ""
			: request.getParameter("AddNewAdmin");

			DBUtil dbutil = new DBUtil(getServletContext());

			if (AddAdminButton.equals("Add New Admin")) {
		boolean addAdminFlag = false;
		addAdminFlag = dbutil.AddNewAdminUser(AddNewAdmin);
		if (addAdminFlag == true) {
%>

<script>
							alert("Admin user added successfully.")
						//	window.opener.history.go();
						//	window.opener.location.href="/st/AdminUserManagement.jsp";
							window.close();
						</script>

<%
} else {
%>

<script>
							alert("Same admin user already exists !!")
						//	window.opener.history.go();
						//	window.opener.location.href="/st/AdminUserManagement.jsp";
							window.close();
						</script>

<%
			}
			}
%>
<html>
<head>
<link type="text/css" rel="stylesheet" href="styles/tracker_style.css">
<title>Manage Admin Users</title>
<script>
		
		
		function checkForEmpty(obj){
		  	
				// alert("obj.value.length"+obj.value);
			
				obj.value = trim(obj.value);
	
				if (obj.value.length == 0 )
				{
					alert("Please enter email id of new Admin user.");
					obj.focus();
					return false;
				}

				document.AddReleaseForm.submit();
				
		}


		function trim(sString)
			{
				sTrimmedString = "";
			   if (sString != "") {
				  var iStart = 0;
				  var iEnd = sString.length - 1;	
				  // var sWhitespace = " \t\f\n\r\v";
				  var sWhitespace = "   ";
		
	
				  while (sWhitespace.indexOf(sString.charAt(iStart)) != -1) {
				  iStart++;
				  if (iStart > iEnd) 
					break;
			   }

			  // If the string not just whitespace
			  if (iStart <= iEnd) {
				 while (sWhitespace.indexOf(sString.charAt(iEnd)) != -1)
					iEnd--;
				 sTrimmedString = sString.substring(iStart,++iEnd);
			  }
		   }
		   return sTrimmedString;
		 }


		</script>
</head>

<body>

<!--
		<form name="updateRelease" method="post">
			<table width=100%>
				<tr>
					<td width=100%>
						<jsp:include page="HeaderNav_ReleaseObject.jsp" />
					</td>
				</tr>
			</table>
		</form>

-->



<form name="AdminUserForm" action="AdminUserManagement.jsp"
	method="post">

<table cellpadding="0" cellspacing="1" width="80%"
	style="BORDER:#000000 1px solid" colspan=2 align=center>

	<tr bgcolor="#000077">
		<td class=smallfonthead width=100% align=left colspan=2><b>Enter
		Email-id of New Admin user.</b></td>
	</tr>

	<tr bgcolor=#EFEFEF>
		<td class=bodyblue width="60%" align=center><input type=text
			name="AddNewAdmin" size="40"></td>
		<td class=bodyblue width="40%" align=center><input type=submit
			class=whitebutton name=AddAdminButton value='Add New Admin'
			onclick="return checkForEmpty(AddNewAdmin)"></td>
	</tr>

	<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<td>&nbsp</td>
	</tr>

</table>
</form>


</body>
</html>

<%
	}
	} catch (Exception e) {
		e.printStackTrace();
	}
%>
